home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_bzip2.idb / usr / freeware / include / bzlib.h.z / bzlib.h
C/C++ Source or Header  |  2000-06-09  |  7KB  |  307 lines

  1.  
  2. /*-------------------------------------------------------------*/
  3. /*--- Public header file for the library.                   ---*/
  4. /*---                                               bzlib.h ---*/
  5. /*-------------------------------------------------------------*/
  6.  
  7. /*--
  8.   This file is a part of bzip2 and/or libbzip2, a program and
  9.   library for lossless, block-sorting data compression.
  10.  
  11.   Copyright (C) 1996-1999 Julian R Seward.  All rights reserved.
  12.  
  13.   Redistribution and use in source and binary forms, with or without
  14.   modification, are permitted provided that the following conditions
  15.   are met:
  16.  
  17.   1. Redistributions of source code must retain the above copyright
  18.      notice, this list of conditions and the following disclaimer.
  19.  
  20.   2. The origin of this software must not be misrepresented; you must 
  21.      not claim that you wrote the original software.  If you use this 
  22.      software in a product, an acknowledgment in the product 
  23.      documentation would be appreciated but is not required.
  24.  
  25.   3. Altered source versions must be plainly marked as such, and must
  26.      not be misrepresented as being the original software.
  27.  
  28.   4. The name of the author may not be used to endorse or promote 
  29.      products derived from this software without specific prior written 
  30.      permission.
  31.  
  32.   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  33.   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  34.   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35.   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  36.   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37.   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  38.   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  39.   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  40.   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  41.   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  42.   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43.  
  44.   Julian Seward, Cambridge, UK.
  45.   jseward@acm.org
  46.   bzip2/libbzip2 version 0.9.5 of 24 May 1999
  47.  
  48.   This program is based on (at least) the work of:
  49.      Mike Burrows
  50.      David Wheeler
  51.      Peter Fenwick
  52.      Alistair Moffat
  53.      Radford Neal
  54.      Ian H. Witten
  55.      Robert Sedgewick
  56.      Jon L. Bentley
  57.  
  58.   For more information on these sources, see the manual.
  59. --*/
  60.  
  61.  
  62. #ifndef _BZLIB_H
  63. #define _BZLIB_H
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. #define BZ_RUN               0
  70. #define BZ_FLUSH             1
  71. #define BZ_FINISH            2
  72.  
  73. #define BZ_OK                0
  74. #define BZ_RUN_OK            1
  75. #define BZ_FLUSH_OK          2
  76. #define BZ_FINISH_OK         3
  77. #define BZ_STREAM_END        4
  78. #define BZ_SEQUENCE_ERROR    (-1)
  79. #define BZ_PARAM_ERROR       (-2)
  80. #define BZ_MEM_ERROR         (-3)
  81. #define BZ_DATA_ERROR        (-4)
  82. #define BZ_DATA_ERROR_MAGIC  (-5)
  83. #define BZ_IO_ERROR          (-6)
  84. #define BZ_UNEXPECTED_EOF    (-7)
  85. #define BZ_OUTBUFF_FULL      (-8)
  86.  
  87. typedef 
  88.    struct {
  89.       char *next_in;
  90.       unsigned int avail_in;
  91.       unsigned int total_in;
  92.  
  93.       char *next_out;
  94.       unsigned int avail_out;
  95.       unsigned int total_out;
  96.  
  97.       void *state;
  98.  
  99.       void *(*bzalloc)(void *,int,int);
  100.       void (*bzfree)(void *,void *);
  101.       void *opaque;
  102.    } 
  103.    bz_stream;
  104.  
  105.  
  106. #ifndef BZ_IMPORT
  107. #define BZ_EXPORT
  108. #endif
  109.  
  110. #ifdef _WIN32
  111. #   include <stdio.h>
  112. #   include <windows.h>
  113. #   ifdef small
  114.       /* windows.h define small to char */
  115. #      undef small
  116. #   endif
  117. #   ifdef BZ_EXPORT
  118. #   define BZ_API(func) WINAPI func
  119. #   define BZ_EXTERN extern
  120. #   else
  121.    /* import windows dll dynamically */
  122. #   define BZ_API(func) (WINAPI * func)
  123. #   define BZ_EXTERN
  124. #   endif
  125. #else
  126. #   define BZ_API(func) func
  127. #   define BZ_EXTERN extern
  128. #endif
  129.  
  130.  
  131. /*-- Core (low-level) library functions --*/
  132.  
  133. BZ_EXTERN int BZ_API(bzCompressInit) ( 
  134.       bz_stream* strm, 
  135.       int        blockSize100k, 
  136.       int        verbosity, 
  137.       int        workFactor 
  138.    );
  139.  
  140. BZ_EXTERN int BZ_API(bzCompress) ( 
  141.       bz_stream* strm, 
  142.       int action 
  143.    );
  144.  
  145. BZ_EXTERN int BZ_API(bzCompressEnd) ( 
  146.       bz_stream* strm 
  147.    );
  148.  
  149. BZ_EXTERN int BZ_API(bzDecompressInit) ( 
  150.       bz_stream *strm, 
  151.       int       verbosity, 
  152.       int       small
  153.    );
  154.  
  155. BZ_EXTERN int BZ_API(bzDecompress) ( 
  156.       bz_stream* strm 
  157.    );
  158.  
  159. BZ_EXTERN int BZ_API(bzDecompressEnd) ( 
  160.       bz_stream *strm 
  161.    );
  162.  
  163.  
  164.  
  165. /*-- High(er) level library functions --*/
  166.  
  167. #ifndef BZ_NO_STDIO
  168. #define BZ_MAX_UNUSED 5000
  169.  
  170. typedef void BZFILE;
  171.  
  172. BZ_EXTERN BZFILE* BZ_API(bzReadOpen) ( 
  173.       int*  bzerror,   
  174.       FILE* f, 
  175.       int   verbosity, 
  176.       int   small,
  177.       void* unused,    
  178.       int   nUnused 
  179.    );
  180.  
  181. BZ_EXTERN void BZ_API(bzReadClose) ( 
  182.       int*    bzerror, 
  183.       BZFILE* b 
  184.    );
  185.  
  186. BZ_EXTERN void BZ_API(bzReadGetUnused) ( 
  187.       int*    bzerror, 
  188.       BZFILE* b, 
  189.       void**  unused,  
  190.       int*    nUnused 
  191.    );
  192.  
  193. BZ_EXTERN int BZ_API(bzRead) ( 
  194.       int*    bzerror, 
  195.       BZFILE* b, 
  196.       void*   buf, 
  197.       int     len 
  198.    );
  199.  
  200. BZ_EXTERN BZFILE* BZ_API(bzWriteOpen) ( 
  201.       int*  bzerror,      
  202.       FILE* f, 
  203.       int   blockSize100k, 
  204.       int   verbosity, 
  205.       int   workFactor 
  206.    );
  207.  
  208. BZ_EXTERN void BZ_API(bzWrite) ( 
  209.       int*    bzerror, 
  210.       BZFILE* b, 
  211.       void*   buf, 
  212.       int     len 
  213.    );
  214.  
  215. BZ_EXTERN void BZ_API(bzWriteClose) ( 
  216.       int*          bzerror, 
  217.       BZFILE*       b, 
  218.       int           abandon, 
  219.       unsigned int* nbytes_in, 
  220.       unsigned int* nbytes_out 
  221.    );
  222. #endif
  223.  
  224.  
  225. /*-- Utility functions --*/
  226.  
  227. BZ_EXTERN int BZ_API(bzBuffToBuffCompress) ( 
  228.       char*         dest, 
  229.       unsigned int* destLen,
  230.       char*         source, 
  231.       unsigned int  sourceLen,
  232.       int           blockSize100k, 
  233.       int           verbosity, 
  234.       int           workFactor 
  235.    );
  236.  
  237. BZ_EXTERN int BZ_API(bzBuffToBuffDecompress) ( 
  238.       char*         dest, 
  239.       unsigned int* destLen,
  240.       char*         source, 
  241.       unsigned int  sourceLen,
  242.       int           small, 
  243.       int           verbosity 
  244.    );
  245.  
  246.  
  247. /*--
  248.    Code contributed by Yoshioka Tsuneo
  249.    (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
  250.    to support better zlib compatibility.
  251.    This code is not _officially_ part of libbzip2 (yet);
  252.    I haven't tested it, documented it, or considered the
  253.    threading-safeness of it.
  254.    If this code breaks, please contact both Yoshioka and me.
  255. --*/
  256.  
  257. BZ_EXTERN const char * BZ_API(bzlibVersion) (
  258.       void
  259.    );
  260.  
  261. #ifndef BZ_NO_STDIO
  262. BZ_EXTERN BZFILE * BZ_API(bzopen) (
  263.       const char *path,
  264.       const char *mode
  265.    );
  266.  
  267. BZ_EXTERN BZFILE * BZ_API(bzdopen) (
  268.       int        fd,
  269.       const char *mode
  270.    );
  271.          
  272. BZ_EXTERN int BZ_API(bzread) (
  273.       BZFILE* b, 
  274.       void* buf, 
  275.       int len 
  276.    );
  277.  
  278. BZ_EXTERN int BZ_API(bzwrite) (
  279.       BZFILE* b, 
  280.       void*   buf, 
  281.       int     len 
  282.    );
  283.  
  284. BZ_EXTERN int BZ_API(bzflush) (
  285.       BZFILE* b
  286.    );
  287.  
  288. BZ_EXTERN void BZ_API(bzclose) (
  289.       BZFILE* b
  290.    );
  291.  
  292. BZ_EXTERN const char * BZ_API(bzerror) (
  293.       BZFILE *b, 
  294.       int    *errnum
  295.    );
  296. #endif
  297.  
  298. #ifdef __cplusplus
  299. }
  300. #endif
  301.  
  302. #endif
  303.  
  304. /*-------------------------------------------------------------*/
  305. /*--- end                                           bzlib.h ---*/
  306. /*-------------------------------------------------------------*/
  307.